package com.woniuxy.controller;

import com.woniuxy.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 曾令忠
 * @Description: 远程调用:A项目调用B项目的接口
 * @Date: 2020/7/6 0006-上午 9:42
 */
@RestController
public class RpcController {

    @Autowired
    private RestTemplate restTemplate;//spring项目中用来调用其他web项目的接口

    @RequestMapping("/all")
    public List<Product> all(){
        String url = "http://localhost:80/product/all";
        List<Product> products = restTemplate.getForObject(url,List.class);
        return  products;
    }

    @RequestMapping("/test")
    public String test(){
        return "111";
    }
}